package defaultPackage;

import java.awt.*;
import java.util.*;
public class AnnouncementMenu 
{
	int textInterval = 16;
	ArrayList<String> Announcements = new ArrayList<String>();
	ArrayList<Color>	color = new ArrayList<Color>();
	int index = 0;
	public void Announcement(String message,Color color)
	{
		Announcements.add(message);
		this.color.add(color);
	}
	public AnnouncementMenu()
	{
		Announcement("You have started a new game. Press / for help.", Color.green);
	}
	public void draw(Graphics g)
	{
		g.setColor(Color.LIGHT_GRAY);
		g.fillRect(0, MainClass.windowYSize-100, MainClass.windowXSize, 100);
		g.setColor(Color.DARK_GRAY);
		g.fillRect(5, MainClass.windowYSize -95, MainClass.windowXSize - 205, 90);
		for (int i = 0;i<Announcements.size();i++)
		{
			int y = MainClass.windowYSize - ((Announcements.size()-i) * textInterval);
			if(y>MainClass.windowYSize - textInterval*6)
			{
			g.setColor(color.get(i));
			g.drawString(Announcements.get(i), 25, y);
			}
		}
		collectGarbage();
		
	}
	
	public void addAnnouncement(String message,Color color)
	{
		Announcements.add(message);
		this.color.add(color);
	}
	
	public void collectGarbage()
	{
		if(Announcements.size() >50)
		{
			Announcements.remove(0);
			color.remove(0);
		}
	}
}
